<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="36-06-手写Promise-then方法的返回值-同步修改状态.js"></script>
</head>

<body>
    <script>
        let p = new Promise((resolve,reject)=>{
            // resolve('success'); 
            reject('error');       
        });

        // console.log(p);

        // then的返回值绝对是promise对象

        // 应该是一个成功的promise 结果值 undefined
        // then的返回值 受 执行函数的返回值影响！
        let p2 = p.then(val=>{
            // console.log(val);
            // return 123;
            return new Promise((res,rej)=>{
                // res('success');
                // rej('error');
            });

            // throw '错误'
        },rea=>{
            // return 666;
            // return new Promise((res,rej)=>{
            //     // res('ok');
            //     // rej('error');
            //     throw '报错'
            // });

            throw 'then报错'

        });

        console.log(p2);

     


       

    </script>
</body>

</html>